<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>

<!-- ========================= -->
<!-- root element: assemblyBuildAcknowledgement -->
<!-- ========================= -->


<xsl:template match="sortBuildAcknowledgement">

	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <!-- ========================= -->
    <!-- gobal variables           -->
    <!-- ========================= -->

    <xsl:variable name="cancelImagePath" select="images//cancelImage"/>
    <xsl:variable name="bgColor" select="bgColor"/>
        <fo:layout-master-set>
            <fo:simple-page-master master-name="simpleA4"
                page-height="11in"
                page-width="8.5in"
                margin-top="5mm"
                margin-bottom="5mm"
                margin-left="17mm"
                margin-right="20mm" >

                <fo:region-before extent="30mm"/>

                <fo:region-after extent="7mm"/>


                <!-- ========================================================  -->
                <!-- Inorder to check whether Sort Release is cancelled or not -->
                <!-- ========================================================  -->

                <xsl:if test="@cancel='0'">
                <fo:region-body />
                </xsl:if>

                <xsl:if test="@cancel='1'">
                <fo:region-body background-image="{$cancelImagePath}" />
                </xsl:if>

            </fo:simple-page-master>
            </fo:layout-master-set>
        <fo:page-sequence master-reference="simpleA4">
            <fo:flow flow-name="xsl-region-body">
                <fo:table table-layout="fixed" width="95%" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column/>
                    <fo:table-body>
                        <fo:table-row background-color="#DEE1E2">
                            <fo:table-cell  border="0.5pt double black" hyphenate="true" display-align="center">
                                <fo:block  text-align="center" font-size="9pt" font-weight="bold">
                                    <xsl:value-of select="vendorName"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row background-color="#DEE1E2">
                            <fo:table-cell  border="0.5pt double black" hyphenate="true" display-align="center">
                                <fo:block text-align="center" font-size="9pt" font-weight="bold">Wafer Sort Request </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row  border="0.5pt double black">
                            <fo:table-cell hyphenate="true" display-align="center" space-before="5mm">
                                <fo:table table-layout="fixed" width="100%" border="0.5pt double black">
                                    <fo:table-column column-width="45mm"/>
                                    <fo:table-column column-width="40mm"/>
                                    <fo:table-column column-width="40mm"/>
                                    <fo:table-column column-width="45mm"/>
                                    <fo:table-body>
                                        <fo:table-row>
                                            <fo:table-cell number-columns-spanned="4">
                                                <fo:block text-align="left" font-size="7pt" font-weight="bold">1.Customer</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt">Customer name</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell number-columns-spanned="2">
                                                <fo:block text-align="left" font-size="7pt" font-weight="bold">
                                                    <xsl:value-of select="customerName"/>
                                                </fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt" font-weight="bold">Customer#       :<xsl:value-of select="customerNumber"/></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt">Customer contact</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt" font-weight="bold">Name</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt" font-weight="bold">Email</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt" font-weight="bold"></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt"></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell number-columns-spanned="2" number-rows-spanned="2">
                                                <fo:table table-layout="fixed" width="100%">
                                                <fo:table-column/>
                                                <fo:table-column/>
                                                <fo:table-body>
                                                    <xsl:for-each select="/sortBuildAcknowledgement/contactPersonDetails/contactPerson">
                                                        <fo:table-row>
                                                            <fo:table-cell>
                                                                <fo:block text-align="left" font-size="7pt"><xsl:value-of select="contactPersonName"/></fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block text-align="left" font-size="7pt"><xsl:value-of select="contactPersonEmail"/></fo:block>
                                                            </fo:table-cell>
                                                        </fo:table-row>
                                                    </xsl:for-each>
                                                </fo:table-body>
                                                </fo:table>
                                            </fo:table-cell>
                                            <fo:table-cell border="0.5pt double black" style="border-left:0.5pt double black;border-bottom:0.5pt double black;border-top:0.5pt double black">
                                                <fo:table table-layout="fixed" width="100%">
                                                <fo:table-column column-width="25mm"/>
                                                <fo:table-column column-width="15mm"/>
                                                <fo:table-body>
                                                    <fo:table-row>
                                                        <fo:table-cell>
                                                            <fo:block text-align="left" font-size="7pt">Date YYYY/DD/MM</fo:block>
                                                        </fo:table-cell>
                                                        <fo:table-cell>
                                                            <fo:block text-align="left" font-size="7pt"><xsl:value-of select="sortDate"/></fo:block>
                                                        </fo:table-cell>
                                                    </fo:table-row>
                                                </fo:table-body>
                                                </fo:table>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block text-align="left" font-size="7pt"></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell border="0.5pt double black" style="border-left:0.5pt double black;border-bottom:0.5pt double black;border-top:0.5pt double black">
                                                <fo:table table-layout="fixed" width="100%">
                                                <fo:table-column column-width="25mm"/>
                                                <fo:table-column column-width="15mm"/>
                                                <fo:table-body>
                                                    <fo:table-row>
                                                        <fo:table-cell>
                                                            <fo:block text-align="left" font-size="7pt">PO #</fo:block>
                                                        </fo:table-cell>
                                                        <fo:table-cell>
                                                            <fo:block text-align="left" font-size="7pt"><xsl:value-of select="sortPONumber"/></fo:block>
                                                        </fo:table-cell>
                                                    </fo:table-row>
                                                </fo:table-body>
                                                </fo:table>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell number-columns-spanned="4">
                                                <fo:block text-align="left" font-size="7pt"></fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell number-columns-spanned="3">
                                                <fo:block text-align="left" font-size="7pt"></fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell border="0.5pt double black" style="border-left:0.5pt double black;border-bottom:0.5pt double black;border-top:0.5pt double black">
                                                <fo:table table-layout="fixed" width="100%">
                                                <fo:table-column column-width="30mm"/>
                                                <fo:table-column column-width="10mm"/>
                                                <fo:table-body>
                                                    <fo:table-row>
                                                        <fo:table-cell>
                                                            <fo:block text-align="left" font-size="7pt" font-weight="bold">Matrix Sort Request # :</fo:block>
                                                        </fo:table-cell>
                                                        <fo:table-cell>
                                                            <fo:block text-align="left" font-size="7pt"><xsl:value-of select="sortRequestNo"/></fo:block>
                                                        </fo:table-cell>
                                                    </fo:table-row>
                                                </fo:table-body>
                                                </fo:table>
                                            </fo:table-cell>
                                        </fo:table-row>
                                    </fo:table-body>
                                </fo:table>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
                <fo:table table-layout="fixed" width="95%" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="4">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">2.0 Device Descriptor</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt"></fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black top">
                                <fo:block text-align="left" font-size="7pt">Matrix Device OPN</fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black top">
                                <fo:block text-align="left" font-size="7pt">
                                    <xsl:value-of select="partNumber"/>
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt"></fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
                <fo:table table-layout="fixed" width="95%" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">3.0 Factory</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt">Factory</fo:block>
                            </fo:table-cell>
                            <fo:table-cell number-columns-spanned="2">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">
                                    <xsl:value-of select="vendorNumber"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt" font-weight="bold"></fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt">Factory contact</fo:block>
                            </fo:table-cell>
                            <fo:table-cell number-columns-spanned="2">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">
                                    <xsl:value-of select="vendorContactPerson"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt" font-weight="bold"></fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt">email</fo:block>
                            </fo:table-cell>
                            <fo:table-cell number-columns-spanned="2">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">
                                    <xsl:value-of select="vendorContactPersonEmail"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
                <fo:table table-layout="fixed" width="95%" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="25mm"/>
                    <fo:table-column column-width="15mm"/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="4">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">4.0 Wafer Information</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt"></fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">Wafer Qty</fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black">
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">
                                    <xsl:value-of select="waferQty"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell border="0.5pt double black">
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">Paper work from TSMC</fo:block>
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">says Fab Lot Number</fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black">
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">Wafer Scribe says</fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black">
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">Fab Lot # to be</fo:block>
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">entered on EG for</fo:block>
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">wafer probe</fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.5pt double black">
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">Wafer # to be</fo:block>
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">entered on EG for</fo:block>
                                <fo:block text-align="center" font-size="7pt" font-weight="bold">wafer probe</fo:block>
                            </fo:table-cell>
                        </fo:table-row>

                        <xsl:for-each select="/sortBuildAcknowledgement/lotDetails/lotData">
                            <xsl:for-each select="waferData">
                                <fo:table-row>
                                    <fo:table-cell border="0.5pt double black">
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="fabLotNumber"/></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="0.5pt double black">
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="waferScribe"/></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="0.5pt double black">
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="fabWaferProbe"/></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="0.5pt double black">
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="waferProbe"/></fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:for-each>
                        </xsl:for-each>
                    </fo:table-body>
                </fo:table>
                <fo:table table-layout="fixed" width="95%" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column/>
                    <fo:table-body>
                        <fo:table-row space-after="0.3cm">
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">5.0 Sort Program Information</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                            <fo:table table-layout="fixed" width="95%" background-color="{$bgColor}">
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell border="0.5pt double black" background-color='#FFFFFF'>
                                        <fo:block text-align="center" font-size="7pt">Matrix Sort Spec </fo:block>
                                    </fo:table-cell >
                                    <fo:table-cell  border="0.5pt double black" background-color='#FFFFFF'>
                                        <fo:block text-align="center" font-size="7pt">Test Spec Rev</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell  border="0.5pt double black" background-color='#FFFFFF'>
                                        <fo:block text-align="center" font-size="7pt"> Test Program Name</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="0.5pt double black" background-color='#FFFFFF'>
                                        <fo:block text-align="center" font-size="7pt">Test Program Revision </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="0.5pt double black" background-color='#FFFFFF'>
                                        <fo:block text-align="center" font-size="7pt">Test Flow </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <fo:table-row>
                                    <fo:table-cell>
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="sortSpec"/></fo:block>
                                    </fo:table-cell >
                                    <fo:table-cell>
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="sortPrgRevision"/></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="testProgramName"/></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="testProgramRevision"/></fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell>
                                        <fo:block text-align="center" font-size="7pt"><xsl:value-of select="testFlow"/></fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </fo:table-body>
                            </fo:table>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
                <fo:table table-layout="fixed" width="95%" height="1cm" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="4">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">6.0 Shipping Requirements</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt"></fo:block>
                            </fo:table-cell>
                            <fo:table-cell number-columns-spanned="3">
                                <fo:block text-align="left" font-size="7pt">
                                    <xsl:apply-templates select="shippingAddress"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row number-columns-spanned="2">
                            <fo:table-cell>
                                <fo:block text-align="left" font-size="7pt" font-weight='bold'>Freight Carrier:<xsl:value-of select="shipperName"/></fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
                <fo:table table-layout="fixed" width="95%" height="2cm" space-after="0.3cm" border="1pt double black" background-color="{$bgColor}">
                    <fo:table-column/>
                    <fo:table-column/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="2">
                                <fo:block text-align="left" font-size="7pt" font-weight="bold">7.0 Special Instructions.</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="2">
                                <fo:block text-align="left" font-size="7pt"></fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="2">
                                <fo:block text-align="left" font-size="7pt"> <xsl:value-of select="comments"/></fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

<!--Shipping Address Block -->
<xsl:template match="shippingAddress">
	<fo:table margin="2mm" width="100%" table-layout="fixed">
		<fo:table-column />
		<fo:table-body>
			<fo:table-row>
				<fo:table-cell display-align="top">
				<fo:block><xsl:value-of select="contactPerson"/></fo:block>
				<fo:block><xsl:value-of select="address1"/></fo:block>
				<fo:block><xsl:value-of select="address2"/></fo:block>
				<fo:block><xsl:value-of select="address3"/></fo:block>
				<fo:block><xsl:value-of select="address4"/></fo:block>
                <fo:block><xsl:value-of select="city"/></fo:block>
                <fo:block><xsl:value-of select="state"/></fo:block>
				<fo:block><xsl:value-of select="phone"/></fo:block>
				<fo:block><xsl:value-of select="fax"/></fo:block>
                <fo:block><xsl:value-of select="cellno"/></fo:block>
                <fo:block><xsl:value-of select="email"/></fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>
</xsl:template>
</xsl:stylesheet>



